<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="./css/wei.css">
    <title>Document</title>
    <style>
        .wei-btn{
            width: 300px;
            height: 46px;
            text-align: center;
            line-height: 46px;
            color: #fff;
            margin: 100px auto;
            border-radius: 5px;
            transition: .3s;
            background:linear-gradient(90deg,rgba(68,137,254,1),rgba(124,136,255,1));
        }
        .wei-btn img{
            display: none;
        }
        .wei-btn span{
            animation: fangda .4s;
        }
        .wei-c-y{
            width: 46px;
            height: 46px;
            border-radius: 50%;
        }
        .wei-c-y .rotate{
            display: block;
            width: 30px;
            height: 30px;
            animation: 2s rotate linear infinite;
        }
        .wei-c-y span{
            display: none;
        }
    </style>
</head>
<body>
    <div class="wei-btn btn-center" id="wei-yuan">
        <img class="rotate" src="./image/bailoading.png" alt="">
        <span class="wei-text">登录</span>
    </div>
    <script src="./js/wei.js"></script>
    <script>
        var wy = document.getElementById('wei-yuan');
        var weiEleWy = weiEle('#wei-yuan'); //traget dom
        wy.onclick = function(){
            startAni()
        }
        function startAni(){
            weiEleWy.addClass('wei-c-y');
            setTimeout(function(){
                endAni(2)
            },4000)
        }
        function endAni(signal){
            weiEleWy.removeClass('wei-c-y');
            signal === 1 ? weiEle('.wei-text').html('请求成功') :  weiEle('.wei-text').html('请求失败');
            weiEle('.wei-text').addClass('fangda')
            renderTimeOut(function(){
               console.log('callback stop')
            },400)
        }
    </script>
</body>
</html>